#include "../include/stu.h"
void enter_cf(){ //文件录入
    system("clear");
    FILE *fp;
    char filepath[20] = "./data/course.txt";
    fp = fopen(filepath,"r");
    struct course *p1,*p2;
    p1 = head2;
    if(fp == NULL){
        printf("can not find file!\n");
        exit(0);
    }
    while(!feof(fp)){
        p2 = (struct course *)malloc(sizeof(struct course));
        fscanf(fp,"%d %s %s %d %d %d %d",&p2->id,p2->name,p2->type,&p2->time,&p2->credit,&p2->selectde,&p2->limit);
        if(p1 == NULL){
            head2 = p2;
            p1 = p2;
        }else{
            p1->next = p2;
            p1 = p2; 
        }
    }
    p1->next = NULL;
    p1 = head2;
    while (p1->next->next != NULL) {
        p1 = p1->next;
    }
    p1->next = NULL;
    fclose(fp);
}
